import { ALL_CATEGORY_ITEM, CATEGORY_NORMAL_DATA } from '@/constants'
import { getCategory } from '@/api/category'
export default {
  namespaced: true,
  state: {
    categorys: CATEGORY_NORMAL_DATA
  },
  mutations: {
    setCategory(state, category) {
      state.categorys = [ALL_CATEGORY_ITEM, ...category]
    }
  },
  actions: {
    async setCategory({ commit }) {
      const { categorys } = await getCategory()
      commit('setCategory', categorys)
    }
  }
}
